from flask_migrate import Migrate
from injector import Module, Binder, Injector
from redis import Redis

from src.extension.extension_db import db
from src.extension.flaskl_migrate_extension import migrate
from src.extension.redis_extension import redis_client
from src.pkg.sqlalchemy import SQLAlchemy


class ExtensionModule(Module):
    """扩展模块的依赖注入"""

    def configure(self, binder: Binder) -> None:
        binder.bind(SQLAlchemy, to=db)
        binder.bind(Migrate, to=migrate)
        binder.bind(Redis, to=redis_client)


injector = Injector([ExtensionModule])
